package jch.learn.java.advanced.chapter2_InputAndOutput;

import java.io.IOException;
import java.nio.file.*;
import java.nio.file.attribute.BasicFileAttributes;

public class TestZIP {

    public static void main(String[] args) throws IOException {
        // Paths类会在默认文件系统中查找路径。
        Path zipPath = Paths.get("java-core-technology-advanced/target/java-core-technology-advanced-1.0-SNAPSHOT.jar");
//        Path zipPath = Paths.get("demo.zip"); // 读取不了7z压缩的zip文件

//        FileSystem fs = FileSystems.newFileSystem(zipPath, ClassLoader.getSystemClassLoader());
        FileSystem fs = FileSystems.newFileSystem(zipPath,null);
        // fs.getPath 对于任意文件系统来说，都与Paths.get类似
        // 查ZIP文件树
        Files.walkFileTree(fs.getPath("/"), new SimpleFileVisitor<Path>() {
            @Override
            public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
                System.out.println(file);
                return FileVisitResult.CONTINUE;
            }
        });
    }
}
